/**
 * 
 */
package com.xjy.ftpmanagment.util;

import java.util.Map;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

/**
 * 检查session中的用户的拦截器
 *
 */
public class AuthorityInterceptor extends AbstractInterceptor {
	
	private static final long serialVersionUID = 1L;

	@SuppressWarnings("unchecked")
	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		ActionContext context = invocation.getInvocationContext();
		// 用户权限检查
		Map session = context.getSession();
		String userID = session.get("userID")==null?"":session.get("userID").toString();
		if (null == userID || userID.equals("")){
			return Page.TOLOGIN;
		}
		return invocation.invoke();
	}

}
